import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.Event;

import ShipModel;
class EnemyShipController
{
  private static inline var EASING:Float = 0.1;
  private var _model:CircleModel;
  private var _playerModel:ShipModel;
  private var _stage:Dynamic;

  public function new(model:CircleModel,playerModel:ShipModel) 
  {
    _model = model;
    _playerModel = playerModel;
    _playerModel.addEventListener(Event.CHANGE, changeHandler);
  }
  public function changeHandler(event:Event)
  {
    _model.friction = 1;
    if(_playerModel.xPos < _model.xPos && _model.vx > -1)
    {
      _model.acceleration_X = -.1;
    }
    else if(_playerModel.xPos > _model.xPos && _model.vx < 1)
    {
      _model.acceleration_X = .1;
    }
    else
    {
      _model.acceleration_X = 0;
    }
    if(_playerModel.yPos < _model.yPos && _model.vy > -1)
    {
      _model.acceleration_Y = -.1;
    }
    else if(_playerModel.yPos > _model.yPos && _model.vy < 1)
    {
      _model.acceleration_Y = .1;
    }
    else
    {
      _model.acceleration_Y = 0;
    }
  }
}